// 管理员登录接口
const express = require('express');
const router = express.Router();
const db = require('../../db/connect');
const jwt = require('jsonwebtoken')
const xzid = require('xzid')

router.get('/loginStudent', (req, res) => {
    // 传入参数 账户、密码
    const { studentcard, password } = req.query;
    const sql = ` select * from manger_student where studentcard = '${studentcard}'  and  password = ${password}`;
    db(sql ,(err, data) => {
        if (data.length>0) {
            const token = jwt.sign({ name: studentcard }, `login`, { expiresIn: 600 });
           res.send({
                code:200,
                data,
                token
           })
        } else {
            res.send({
                code: 400,
                content: err,
                message: '告诉他账户不存在'
            })
        }
    })
})
module.exports = router